package com.woniu.rabbit.simple_model.producer;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 生产者
 * */
@Slf4j
@RestController
@RequestMapping("/producer")
@Api(tags ="生产者")
public class SimpleProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping(value = "/simple")
    @ApiOperation("简单模式生产者")
    public ResponseEntity send(String msg){
        log.info("生产者发送消息：" + msg);
        rabbitTemplate.convertAndSend("simple.queue",msg);
        return ResponseEntity.ok("消息发送成功");
    }
}
